<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新闻明细</title>
</head>
<body>
<h1>新闻明细</h1>
<button id="back">返回</button>
<div id="content"></div>

<script src="../resources/jquery-2.1.4.js"></script>
<script src="../resources/common.js"></script>
<script>
    $(function (){
        init();
        $("#back").click(function (){
            location.href = "index.html";
        });
    });

    function init() {
        if (params.id){
            $.ajax({
                url: baseUrl+"/news/"+params.id,
                type: 'GET',
                dataType: 'json',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        var model = result.model;
                        var content = $("#content");
                        content.append($("<h2>"+model.title+"</h2><hr/>"));
                        content.append($("<p>"+model.newsContent+"</p><hr/>"));
                        content.append($("<p>发布者："+model.publisher+"</p>"));
                        content.append($("<p>发布时间："+model.gmtCreate+"</p>"));
                        if (model.gmtModify!= null) {
                            content.append($("<p>修改时间："+model.gmtModify+"</p>"));
                        }
                    } else {
                        alert(result.msg);
                    }
                }
            });
        }
    }
</script>
</body>
</html>
